const { Schema, model, Types } = require('mongoose')
const User = require('../userModels/userModel')
const avatarSchema = new Schema({
    avatarId: {
        type: Types.ObjectId,
        ref: 'User'
    },
    name: {
        type: String,
        required: true
    },
    url: {
        type: String,
        required: true
    },
    mimetype: String,
    size: Number,
    uploadDate: {
        type: Date,
        default: Date.now
    }
})

// 添加文本索引方便搜索
avatarSchema.index({ name: 'text' });

module.exports = model('Avatar', avatarSchema);

